package cc.linker.steplink.crm.merchant.service.impl;

import cc.linker.steplink.crm.merchant.dao.acs.PromoterAccountDao;
import cc.linker.steplink.crm.merchant.pojo.PromoterAccountPo;
import cc.linker.steplink.crm.merchant.pojo.PromoterPersonalAccountPo;
import cc.linker.steplink.crm.merchant.service.acs.PromoterAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PromoterAccountServiceImpl implements PromoterAccountService {

    @Autowired
    private PromoterAccountDao promoterAccountDao;

    @Override
    public List<PromoterAccountPo> findPromoterList(Map map) {
        return promoterAccountDao.findPromoterList(map);
    }

    @Override
    public void updateAccount(Map<Object, Object> map) {
        promoterAccountDao.updateAccount(map);
    }

    @Override
    public List<PromoterPersonalAccountPo> findPromoterAccount(String customerId) {
        return promoterAccountDao.findPromoterAccount(customerId);
    }

    @Override
    public String findAdminName(String adminId) {
        return promoterAccountDao.findAdminName(adminId);
    }

    @Override
    public List<PromoterAccountPo> findPromoterBusiList(Map<String, Object> searchMap) {
        return promoterAccountDao.findPromoterBusiList(searchMap);
    }

    @Override
    public Integer findAmount(String customerId) {
        return promoterAccountDao.findAmount(customerId);
    }

    @Override
    public Integer findBusiAmount(String customerId) {
        return promoterAccountDao.findBusiAmount(customerId);
    }

    @Override
    public Integer findReturnAmount(String customerId) {
        return promoterAccountDao.findReturnAmount(customerId);
    }

    @Override
    public Integer findBookeep(String customerId) {
        return promoterAccountDao.findBookeep(customerId);
    }

    @Override
    public List<Map<String, Object>> agentList(String customerId) {
        return promoterAccountDao.agentList(customerId);
    }

    @Override
    public Long getAmount(String customerID, String startTime, String endTime) {
        // 获取满足条件的用户ID
        String customerIds = promoterAccountDao.getCustomerIDS(customerID);
        Long tradeMoney = promoterAccountDao.getAmount(customerIds, startTime, endTime);
        Long tradeScoreMoney = promoterAccountDao.getScoreAmount(customerIds, startTime, endTime);
        return tradeMoney + tradeScoreMoney;
    }
}
